package logic

import (
	"context"
	"manage/managerpc/managerpc"

	"manage/api/internal/svc"
	"manage/api/internal/types"

	"github.com/zeromicro/go-zero/core/logx"
)

type PerfectLogic struct {
	logx.Logger
	ctx    context.Context
	svcCtx *svc.ServiceContext
}

func NewPerfectLogic(ctx context.Context, svcCtx *svc.ServiceContext) *PerfectLogic {
	return &PerfectLogic{
		Logger: logx.WithContext(ctx),
		ctx:    ctx,
		svcCtx: svcCtx,
	}
}

func (l *PerfectLogic) Perfect(req *types.PerfectRequest) (resp *types.Response, err error) {
	// todo: add your logic here and delete this line

	sms, err := l.svcCtx.ManageRpc.Perfect(l.ctx, &managerpc.PerfectRequest{
		Name:          req.Name,
		ManageContext: req.ManageContext,
		HeadImage:     req.HeadImage,
		Id:            req.Id,
	})
	if err != nil {
		return &types.Response{
			Message: err.Error(),
			Code:    500,
			Data:    nil,
		}, nil
	}
	return &types.Response{
		Message: "完善成功",
		Code:    200,
		Data:    sms,
	}, nil
}
